home *** CD-ROM | disk | FTP | other *** search
/ Day Cry / Day Cry CD.bin / oh_towns / taropyon / splib / splib.lzh / PRG / ZNSPLAY / MAIN.C < prev    next >
C/C++ Source or Header  |  1994-09-19  |  10KB  |  396 lines

  1. /*************************************************************************
  2. *    "ZNSPLAY"
  3. *************************************************************************/
  4.  
  5.  
  6. #include    <stdio.h>
  7. #include    <stdlib.h>
  8. #include    <ctype.h>
  9. #include    <string.h>
  10. #include    <time.h>
  11. #ifdef    __HIGHC__
  12. #    include    <heap.cf>
  13. #endif
  14.  
  15. #include    <egb.h>
  16. #include    <mos.h>
  17. #include    <snd.h>
  18. #include    <xld.h>
  19. #include    <sidework.h>
  20. #include    <loader.h>
  21.  
  22. #include    "znsplay.h"
  23. #include    "../DLL/BGM/midi.h"
  24.  
  25. #include    <setint.h>
  26. #include    <doscons.h>
  27. #include    <spgetopt.h>
  28. #include    <fdl.h>
  29. #include    <FDL/fdlcol.h>
  30. #include    <dta.h>
  31. #include    <dtaname.h>
  32.  
  33. extern int        SideWorkMenu(void);
  34.  
  35. int                        FlagQuickRet = FALSE;
  36. static CONST char        RECODENAME_MAINARG[]   = DTA_RECODENAME_MAINARG;
  37. static CONST char        RECODENAME_STARTPATH[] = DTA_RECODENAME_STARTPATH;
  38. DTACTRL_T               *DtaCtrl = NULL;
  39.  
  40. static    PLT_RGB    PltDat[16] =
  41. {
  42.     /* G R  B                                */
  43.     { 0, 0, 0},    /* C_BALCK                    */
  44.     { 0, 0, 0},    /* C_BLUE or C_THROUGH        */
  45.     { 7, 7, 8},    /* C_RED                    */
  46.     {12,12,13},    /* C_MAGENTA                */
  47.     { 6, 5, 7},    /* C_GREEN                    */
  48.     { 8, 7, 9},    /* C_CYAN                    */
  49.     {10, 9,11},    /* C_YELLOW                    */
  50.     {11,11,12},    /* C_WHITE                    */
  51.  
  52.     { 5, 5, 6},    /* C_HBALCK                    */
  53.     { 0, 0,11},    /* C_HBLUE                    */
  54.     { 0,11, 0},    /* C_HRED                    */
  55.     { 0,11,11},    /* C_HMAGENTA                */
  56.     {11, 0, 0},    /* C_HGEEN                    */
  57.     {11, 0,11},    /* C_HCYAN                    */
  58.     {11,11, 0},    /* C_HYELLOW                */
  59.     {14,14,15}    /* C_HWHITE                    */
  60. };
  61.  
  62.  
  63. POINT        DisplayStartPara[4] = 
  64. {
  65.     {0,0},        /* ëµû╩é╠ò\ĪèJÄnêΩé╠É▌ÆΦ    */
  66.     {0,0},        /* ë╝æzëµû╩Æåé╠ê┌ô«            */
  67.     {2,2},        /* ëµû╩é╠ègæσ                */
  68.     {320,240},    /* ò\Īëµû╩é╠æσé½é│            */
  69. };
  70.  
  71. void    page1_palette(void)
  72. {
  73.     DSP_writePage(1);
  74.     DSP_setPlt(PltDat);
  75. }
  76.  
  77. void    ZNS_displayStart( int mode, int x, int y )
  78. {
  79.     DisplayStartPara[mode].x = x;
  80.     DisplayStartPara[mode].y = y;
  81.     EGB_displayStart(EgbPtr, mode, DisplayStartPara[mode].x,
  82.                                    DisplayStartPara[mode].y );
  83. }
  84.  
  85. #if    0
  86. void    reinit(void)
  87. {
  88.     int        page;
  89.  
  90.     {
  91.         int        i;
  92.         page = 0;
  93.         for ( i = 0; i < 4; ++i )
  94.         {
  95.             EGB_displayStart(EgbPtr, i, DisplayStartPara[i].x,
  96.                                         DisplayStartPara[i].y );
  97.         }
  98.     }
  99.     {
  100.         page = 1;
  101.         EGB_writePage(EgbPtr, page );
  102.         EGB_displayStart(EgbPtr, 1, DspCtrl.scinf[page].dspstart.x,
  103.                                     DspCtrl.scinf[page].dspstart.y );
  104.         EGB_displayStart(EgbPtr, 3, DspCtrl.scinf[page].sc.x2+1,
  105.                                     DspCtrl.scinf[page].sc.y2+1 );
  106.     }
  107.  
  108.     MOS_setControl(0x7F);
  109.     MOS_resolution(0,DspCtrl.page0);
  110.     MOS_resolution(1,DspCtrl.page1);
  111.     MOS_writePage(MosInf.page);
  112.     MOS_curType( 81 );
  113.     MosInf.move = DspCtrl.scinf[MosInf.page].sc;
  114.     MOS_moveArea( MosInf.move.x1, MosInf.move.y1,
  115.                   MosInf.move.x2, MosInf.move.y2 );
  116.  
  117.     page1_palette();
  118. }
  119. #endif
  120.  
  121. /*************************************************************************
  122. *    âVâXâeâÇÅëè·ë╗
  123. *************************************************************************/
  124. static int        init( int *argc, char **argv[], int _argc, char **_argv )
  125. {
  126. #ifdef    __HIGHC__
  127.     /* âüâéâèĵô╛ùpÉ▌ÆΦ    */
  128.     Init_allocated_storage = 0;
  129. #endif
  130.  
  131.     *argc = _argc;
  132.     *argv = _argv;
  133.     if ( DTA_isAtPcl() )
  134.     {
  135.         /* ÄqâvâìâZâXïNô«    */
  136.         DTARECODE_T    *recode_arg = NULL, *recode_startpath = NULL;
  137.         char        *args = "ZNSPLAY";
  138.         char        *startpath = NULL;
  139.  
  140.         if ( (DtaCtrl = DTA_openCheck()) != NULL )
  141.         {
  142.             if ( (recode_arg = DTA_openRecode( DtaCtrl, RECODENAME_MAINARG)) != NULL )
  143.             {    /* âpâëâüü[â^é╠ÄwÆΦéáéΦ    */
  144.                 args = recode_arg->ptr;
  145.             }
  146.             if ( (recode_startpath = DTA_openRecode( DtaCtrl, RECODENAME_STARTPATH)) != NULL )
  147.             {    /* âpâëâüü[â^é╠ÄwÆΦéáéΦ    */
  148.                 startpath = recode_startpath->ptr;
  149.             }
  150.         }
  151.         if ( (*argc = FS_argSet( args, argv )) < 1 )
  152.             return (ERR);
  153.         if ( startpath )
  154.             *argv[0] = startpath;
  155.     }
  156.  
  157.     set_ctrl_c();
  158.     set24h();
  159.  
  160.     if ( SndPtr == NULL )
  161.     {
  162.         if ( (SndPtr = calloc(16384,1)) == NULL )
  163.         {
  164.             reset24h();
  165.             return (ERR);
  166.         }
  167.         SND_init( SndPtr );
  168.     }
  169.  
  170.     {
  171.         DSP_sysInit(NULL);
  172.  
  173.         EGB_displayPage(EgbPtr,0,0);
  174.         EGB_resolution(EgbPtr,0,ZNS_RESOLUSION);    /* ëµû╩âéü[âhÉ▌ÆΦ    */
  175.         EGB_displayStart(EgbPtr,2,2,2);
  176.         EGB_displayStart(EgbPtr,3,320,240);
  177.         EGB_displayPage(EgbPtr,1,3);
  178.  
  179.         DspCtrl.page0              = ZNS_RESOLUSION;
  180.         DspCtrl.scinf[0].md        = ZNS_RESOLUSION;
  181.  
  182.         DspCtrl.scinf[0].fr.x1      = 0;
  183.         DspCtrl.scinf[0].fr.y1      = 0;
  184.         DspCtrl.scinf[0].fr.x2      = 511;
  185.         DspCtrl.scinf[0].fr.y2      = 255;
  186.         DspCtrl.scinf[0].sc.x1      = 0;
  187.         DspCtrl.scinf[0].sc.y1      = 0;
  188.         DspCtrl.scinf[0].sc.x2      = 319;
  189.         DspCtrl.scinf[0].sc.y2      = 239;
  190.         DspCtrl.scinf[0].view.x1    = 0;
  191.         DspCtrl.scinf[0].view.y1    = 0;
  192.         DspCtrl.scinf[0].view.x2    = 319;
  193.         DspCtrl.scinf[0].view.y2    = 239;
  194.         DspCtrl.scinf[0].dlgArea.x1 = 2;
  195.         DspCtrl.scinf[0].dlgArea.y1 = 14;
  196.         DspCtrl.scinf[0].dlgArea.x2 = 319-2;
  197.         DspCtrl.scinf[0].dlgArea.y2 = 239-10;
  198.         MosInf.scrollPage = 0xFF;        /* âXâNâìü[âïé╚é╡    */
  199.     }
  200.  
  201.     DSP_set_defFnt( FNTYPE_USR1 );
  202.     GetFnt12Ptr(0);                /* ank font 12 Åëè·É▌ÆΦ        */
  203.     KBF_sysInit();                /* âLü[â{ü[âhâVâXâeâÇÅëè·ë╗    */
  204.     KBF_kan_off();                /* é⌐é╚è┐ÄÜò╧è╖ï╓Ä~            */
  205.     FDL_sysInit();                /* âtâ@âCâïâ_âCâAâìâO        */
  206.     sdk_control(0);                /* âTâCâhâÅü[âNïNô«ï╓Ä~        */
  207.  
  208.     /* DLL âVâXâeâÇÅëè·ë╗    */
  209.     _XLD_init(NULL);
  210.     _XLD_setMemFunc( malloc, free );
  211.     {
  212.         char    tmp[256];
  213.         int        len;
  214.  
  215.         FS_setStartPath( tmp, *argv[0] );
  216.         if ( (len = strlen(tmp)) > 0 )
  217.             tmp[--len] = '\0';
  218.         _XLD_setLinkPath( tmp );
  219.     }
  220.     _XLD_lockLib( MID_playStatFlag );
  221.  
  222.     /* MIDI BGM âVâXâeâÇÅëè·ë╗    */
  223.     MID_sysInit();
  224.  
  225.     /* âpâîâbâgÉ▌ÆΦ    */
  226.     DSP_writePage(1);
  227.     DSP_setPlt(PltDat);
  228.  
  229.     /*    â^âCâgâïò\Ī    */
  230.     DSP_writePage(1);
  231.     DSP_title( _ZNSPLAY_, MAIN_VER, C_HWHITE, C_WHITE, C_MBLACK, C_HBLACK );
  232.  
  233.     /* âtâ@âCâïâ_âCâAâìâO    */
  234.     FdlDefColTbl[0] = C_DLGBASE;
  235.     Fdl_set_doscall( DOScons_open, DOScons_close, system);
  236.     Fdl_set_sidework( SideWorkMenu );
  237.     FdlSetWildCardList( ZNS_WILD_ALL );
  238.     FdlSetWildCardList( ZNS_WILD_MOV );
  239. /*    FdlSetWildCardList( ZNS_WILD_V00 );    */
  240.     FdlSetWildCardList( ZNS_WILD_V02 );
  241.  
  242.     return (NORMAL);
  243. }
  244.  
  245. static void    term(void)
  246. {
  247.     EGB_writePage(EgbPtr,0);
  248.     EGB_color(EgbPtr,1,0);
  249.     EGB_clearScreen(EgbPtr);
  250.  
  251.     DSP_writePage(1);
  252.     HVboxf(DspCtrl.scinf[1].sc.x1, DspCtrl.scinf[1].sc.y1+DspTitYs,
  253.            DspCtrl.scinf[1].sc.x2, DspCtrl.scinf[1].sc.y2-16,0);
  254.  
  255.     MID_sysEnd();
  256.     FDL_sysEnd();
  257.     KBF_sysEnd();
  258.     DSP_sysEnd();
  259.  
  260.     if ( SndPtr )
  261.     {
  262.         SND_end();
  263.         free(SndPtr);
  264.         SndPtr = NULL;
  265.     }
  266.  
  267.     reset24h();
  268. }
  269.  
  270. static    void    help(void)
  271. {
  272.     static CONST char    help_msg[] = "\
  273.      usage : znsplay [<option>] [<filename>]    \n\
  274.      <option>                                   \n\
  275.        -wait <n>    ... wait time (n:0ü`99)     \n\
  276.        -display <n> ... display mode (n:1ü`4)   \n\
  277.        -disk        ... disk play mode          \n\
  278.        -memory      ... memory play mode        \n\
  279.        -chkPort <right/left/both>               \n\
  280.                     ... pause & stop check port \
  281. ";
  282.  
  283.     DSP_writePage(1);
  284.     DLG_tmpMsgBox ( DLGPOS_CENTER_OF_SCN, DLGPOS_CENTER_OF_SCN,
  285.         DspCtrl.black, C_DLGBASE, COLMIX(C_INFO,C_GRAY),
  286.         "ügUGOKUZANSUüh movie data player  %s ver.%s\n\n%s",
  287.         _ZNSPLAY_, MAIN_VER, help_msg );
  288.  
  289. }
  290.  
  291. static int        errFunc( CONST char *s )
  292. {
  293.     /* return (-1) æªÆåÆf               */
  294.     /* return (1)  âGâëü[é═û│Äïé╡é─ÆåÆf */
  295.     /* return (0)  âGâëü[é═û│Äï         */
  296.  
  297.     return (0);
  298. }
  299.  
  300. /*************************************************************************
  301. *    âIâvâVâçâôâpâëâüü[â^é╠ë≡É═ü^É▌ÆΦ
  302. *************************************************************************/
  303.  
  304. static int        set_option( int argc, char **argv )
  305. {
  306.     int                        ret = NORMAL;
  307.     static int                helpVar    = 0;
  308.     static GOP_DIGIT_T        waitPar    = { 0, 0, 99 };
  309.     static GOP_DIGIT_T        displayPar = { 1, 1, 4 };
  310.     static int                memoryVar  = 0;
  311.     static int                diskVar    = 0;
  312.     extern int                ZnsSwPort;
  313.     static GOP_SELECT_OBJ_T    ZnsSwPortObj[3] =
  314.     {
  315.         {1,"left" },
  316.         {2,"right"},
  317.         {3,"both" },
  318.     };
  319.     static    GOP_SELECT_T    ZnsSwPortPar = {3, ZnsSwPortObj};
  320.  
  321.     static    GOPKEY_T    GetoptKey[] = 
  322.     {
  323.         { GOP_TYP_FLAG  , "?"             , GO